/**
 * Usage:   <script src="https://epp-jslib.googlecode.com/hg-history/tip/src/epp-string.js"></script>
 **/

/*
 * '10'.pad(4);      // 0010
 * '9'.pad(4);       // 0009
 * '123'.pad(4);     // 0123
 * 
 * '10'.pad(4, '-'); // --10
 */
String.prototype.pad = function(width, z) {
	z = z || '0';
	var n = this + '';
	return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}